package com.atguigu.ssyx.home.controller;

import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.common.security.AuthContextHolder;
import com.atguigu.ssyx.home.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@Api(tags = "商品详细")
@RequestMapping("/api/home")
@RequiredArgsConstructor
public class ItemApiController {
    private  final ItemService  itemService ;


    @ApiOperation("获取sku详细信息")
    @GetMapping("/item/{id}")
    public Result index(@PathVariable Long id, HttpServletRequest request){

        Long userId = AuthContextHolder.getUserId();
        Map<String, Object> map= itemService.getItemInfo(id,userId);
        return Result.ok(map);
    }
}
